package com.clubs.coding.Service.Impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.clubs.coding.Service.ConstantAdminService;
import com.clubs.coding.exception.ImoocMallException;
import com.clubs.coding.exception.ImoocMallExceptionEnum;
import com.clubs.coding.model.Vo.AnalysisVo;
import com.clubs.coding.model.Vo.DataVo;
import com.clubs.coding.model.dao.ClassifyLinkmanMapper;
import com.clubs.coding.model.pojo.ClassifyLinkman;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConstantAdminServiceImpl implements ConstantAdminService {
@Autowired
    ClassifyLinkmanMapper classifyLinkmanMapper;
//@Override
//public PageInfo list(Integer pageNum, Integer pageSize, Integer isHome){
//    PageHelper.startPage(pageNum, pageSize,"creation_time desc ");
//    List<News> newsList = new ArrayList<>();
//    if (isHome==1) {
//        newsList = newsMapper.selectAllByShowIndexNews();
//    }else{
//        newsList = newsMapper.selectAll();
//    }
//    PageInfo pageInfo = new PageInfo(newsList);
//    pageInfo.setList(newsList);
//   return pageInfo;
//}
@Override
public List<ClassifyLinkman> linkman(){
    List<ClassifyLinkman> classifyLinkmen = classifyLinkmanMapper.selectAll();
    if (classifyLinkmen==null) {
        throw new ImoocMallException(ImoocMallExceptionEnum.LINKMAN_NULL);
    }
    return classifyLinkmen;
}
@Override
public String dataAnalysis(){
    //每月开通会员个数
    AnalysisVo analysisVo = new AnalysisVo();
    analysisVo.setVipData(CollectionUtil.newArrayList(
            new DataVo("1月",10),
            new DataVo("2月",25),
            new DataVo("3月",47),
            new DataVo("4月",89),
            new DataVo("5月",105)
    ));
    analysisVo.setAppliData(CollectionUtil.newArrayList(
            new DataVo("1月",350),
            new DataVo("2月",1500),
            new DataVo("3月",1800),
            new DataVo("4月",2540),
            new DataVo("5月",3520)
    ));
    analysisVo.setLeaveData(CollectionUtil.newArrayList(
            new DataVo("1月",5),
            new DataVo("2月",10),
            new DataVo("3月",25),
            new DataVo("4月",52),
            new DataVo("5月",66)
    ));
    analysisVo.setMakeData(CollectionUtil.newArrayList(
            new DataVo("1月",500),
            new DataVo("2月",750),
            new DataVo("3月",853),
            new DataVo("4月",986),
            new DataVo("5月",1125)
    ));
    analysisVo.setMarkData(CollectionUtil.newArrayList(
            new DataVo("1月",320),
            new DataVo("2月",1480),
            new DataVo("3月",1750),
            new DataVo("4月",3350),
            new DataVo("5月",4025)
    ));

    JSONObject json = JSONUtil.parseObj(analysisVo, false);

//    Map<String, Object> vipMap = new HashMap<String, Object>();
//    vipMap.put("1月", "10");
//    vipMap.put("2月", "25");
//    vipMap.put("3月", "47");
//    vipMap.put("4月", "89");
//    vipMap.put("5月", "105");
//每月报名次数
//    Map<String, Object> appliMap = new HashMap<String, Object>();
//    appliMap.put("1月", "350");
//    appliMap.put("2月", "1500");
//    appliMap.put("3月", "1800");
//    appliMap.put("4月", "3540");
//    appliMap.put("5月", "4620");
//    //每月请假人数
//    Map<String, Object> leaveMap = new HashMap<String, Object>();
//    leaveMap.put("1月", "5");
//    leaveMap.put("2月", "10");
//    leaveMap.put("3月", "25");
//    leaveMap.put("4月", "52");
//    leaveMap.put("5月", "66");
//    //每月开课数量
//    Map<String, Object> makeMap = new HashMap<String, Object>();
//    makeMap.put("1月", "500");
//    makeMap.put("2月", "750");
//    makeMap.put("3月", "853");
//    makeMap.put("4月", "965");
//    makeMap.put("5月", "1000");
//    //每月给孩子记录打分的次数
//    Map<String, Object> markMap = new HashMap<String, Object>();
//    markMap.put("1月", "320");
//    markMap.put("2月", "1480");
//    markMap.put("3月", "1750");
//    markMap.put("4月", "3350");
//    markMap.put("5月", "4025");
//    List List = new ArrayList();
//    List.add(json);
//    List.add(appliMap);
//    List.add(leaveMap);
//    List.add(makeMap);
//    List.add(markMap);
    return json.toStringPretty();
}

}
